import Mock from 'mockjs'
export default {
  getMenu: config => {
    console.log(config);
    const { username, password } = JSON.parse(config.body)
    console.log(JSON.parse(config.body))
    // 先判断用户是否存在
    // 判断账号和密码是否对应
    if (username === 'admin' && password === 'admin') {
      return {
        code: 20000,
        data: {
          menu: [
            {
              path:'/',
              name:'home',
              label:'首页',
              icon:'s-home',
              url:'home/index'
            },
            {
              path:'/User',
              name:'User',
              label:'用户管理',
              icon:'user',
              url:'User/index'
            },
            {
              label:'订单管理',
              icon:'location',
              child:[
                {
                  path:'/all-orders',
                  name:'all-orders',
                  label:'所有订单',
                  url:'order/all-orders'
                },
                {
                  path:'/obligation',
                  name:'obligation',
                  label:'待付款',
                  url:'order/obligation'
                },
                {
                  path:'/wait-deliver',
                  name:'wait-deliver',
                  label:'待发货',
                  url:'order/wait-deliver'
                },
                {
                  path:'/wait-receive',
                  name:'wait-receive',
                  label:'待团长收货',
                  url:'order/wait-receive'
                },
                {
                  path:'/wait-receive-user',
                  name:'wait-receive-user',
                  label:'待用户取货',
                  url:'order/wait-receive-user'
                },
                {
                  path:'/completed',
                  name:'completed',
                  label:'已完成',
                  url:'order/completed'
                },
                {
                  path:'/refunded',
                  name:'refunded',
                  label:'已退款',
                  url:'order/refunded'
                },
                {
                  path:'/closed',
                  name:'closed',
                  label:'已关闭',
                  url:'order/closed'
                },
                {
                  path:'/distribution-mode',
                  name:'distribution-mode',
                  label:'配送方式',
                  url:'order/distribution-mode'
                },
              ]
            }
          ],
          token: Mock.Random.guid(),
          message: '获取成功'
        }
      }
    } else if (username === 'xiaoxiao' && password === 'xiaoxiao') {
      return {
        code: 20000,
        data: {
          menu: [
            {
              path: '/',
              name: 'home',
              label: '首页',
              icon: 's-home',
              url: 'Home/Home'
            },
            {
              path: '/video',
              name: 'video',
              label: '商品管理',
              icon: 'video-play',
              url: 'VideoManage/VideoManage'
            }
          ],
          token: Mock.Random.guid(),
          message: '获取成功'
        }
      }
    } else {
      return {
        code: -999,
        data: {
          message: '密码错误'
        }
      }
    }

  }
}
